<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>{$row['title']}</title>
</head>
<script src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/jquery.1.9.1.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/layer_mobile/layer.js"></script>
    <link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/layer.css" />
<style>
	*{margin: 0;padding: 0;}
	a,a:hover,a:active,a:visited,a:link,a:focus{
	
	-webkit-tap-highlight-color:rgba(0,0,0,0);
	
	-webkit-tap-highlight-color: transparent;
	
	outline:none;
	
	background: none;
	
	text-decoration: none;
	
	}
	img{width: 100%;display: block;}
	body{background-color: #ffcc00;}
</style>
<body>
	<a href="javascript:;" class="dotm_btn1"><img src="http://oaimg.fc62.com/{$row['page_image']}"/></a>
</body>
</html>
<script type="text/javascript" charset="utf-8">
  wx.config({$jssdk});
</script>
<script>
	var type = {$row['id']};
  $(function(){

    $('.dotm_btn1').click(function(){
            //添加禁止标签
            $('.dotm_btn1').attr("disabled","disabled");
            var index = layer.open({type: 2});
            $.ajax({
              type: 'post',
              url:"/api/ques/single" ,
              data:{type:type},
              success: function(data){
                if(data.code != 0){
                  wx.chooseWXPay({
                    timestamp: data.data.timeStamp,
                    nonceStr: data.data.nonceStr,
                    package: data.data.package,
                    signType: data.data.signType,
                    paySign: data.data.paySign, // 支付签名
                    success: function (res) {
                    // 支付成功后的回调函数
                      if (res.errMsg == "chooseWXPay:ok") {
                         setTimeout(function () {
                           layer.close(index);
                           window.location.href="/index/ques/single_success/ids/{$row['id']}";
                        },1000);
                        // alert('支付成功');
                        
                        // window.location.reload();
                        $('.dotm_btn1').removeAttr("disabled");
                      } else {
                        alert(res.errMsg,null);
                        $('.dotm_btn1').removeAttr("disabled");
                      }
                    },
                    cancel: function(r) {
                      layer.close(index);
                       layer.open({
                        content: '取消支付',
                        skin: 'msg',
                        time: 2, //2秒后自动关闭
                      });
                      $('.dotm_btn1').removeAttr("disabled");
                    },
                    fail:function(r){
                      layer.close(index);
                      layer.open({
                        content: 'fail支付失败了',
                        skin: 'msg',
                        time: 2, //2秒后自动关闭
                      });
                      $('.dotm_btn1').removeAttr("disabled");
                      //支付失败
                    }

                });
                  // layer.open({
                  //   content: data.msg,
                  //   skin: 'msg',
                  //   time: 2, //2秒后自动关闭
                  //   end:function(){
                  //     window.location.reload()
                  //   }
                  // });
                  //调取微信支付 6元

                }else{
                  layer.close(index);
                  layer.open({
                    content: data.msg,
                    skin: 'msg',
                    time: 2, //2秒后自动关闭
                  });
                  if(data.msg == '已经支付，不可重复支付'){
                     setTimeout(function () {
                      window.location.href="/index/ques/single_success/ids/{$row['id']}";
                     },1000);
                  }
                }

              }
            });

    });
  });




</script>